using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace DC1
{
    public class DependencyElementCollection : ConfigurationElementCollection
    {
        public DependencyElement this[int index]
        {
            get
            { return (DependencyElement)base.BaseGet(index); }
            set
            {
                if (base.BaseGet(index) != null)
                    base.BaseRemoveAt(index);

                this.BaseAdd(index, value);
            }
        }
        protected override bool IsElementName(string elementName)
        {
            if ((string.IsNullOrEmpty(elementName)) || (elementName != "dependency"))
                return false;
            return true;
        }
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMapAlternate;
            }
        }
        protected override ConfigurationElement CreateNewElement()
        {
            return new DependencyElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((DependencyElement)element)._ElementName;
        }
    }
    public class OSElementCollection : ConfigurationElementCollection
    {
        public OSElement this[int index]
        {
            get
            { return (OSElement)base.BaseGet(index); }
            set
            {
                if (base.BaseGet(index) != null)
                    base.BaseRemoveAt(index);

                this.BaseAdd(index, value);
            }
        }
        protected override bool IsElementName(string elementName)
        {
            if ((string.IsNullOrEmpty(elementName)) || (elementName != "os"))
                return false;
            return true;
        }
        public override ConfigurationElementCollectionType CollectionType
        {
            get
            {
                return ConfigurationElementCollectionType.BasicMapAlternate;
            }
        }
        protected override ConfigurationElement CreateNewElement()
        {
            return new OSElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((OSElement)element)._ElementName;
        }
    }
    public class DependenciesSection : ConfigurationSection
    {
        [ConfigurationProperty("dependencyGroup", IsDefaultCollection = true, IsRequired = true)]
        public OSElementCollection Dependency
        {
            get { return ((OSElementCollection)base["dependencyGroup"]); }
        }

 

    }
    public class OSElement : ConfigurationElement
    {
        internal string _ElementName = "dependencyGroup";
        public OSElement()
        {
        }
        
        protected override bool SerializeElement(System.Xml.XmlWriter writer, bool serializeCollectionKey)
        {
            bool result = false;
            if (!base.SerializeElement(null, false))
                return false;

            if (writer != null)
            {
                writer.WriteStartElement(this._ElementName);
                result |= base.SerializeElement(writer, false);
                writer.WriteEndElement();
                return result;
            }

            return (result | base.SerializeElement(writer, false));
        }
        [ConfigurationProperty("buildNumber", IsRequired = true)]
        public string BuildNumber
        {
            get { return (string)base["buildNumber"]; }
            set { base["buildNumber"] = value; }
        }
        [ConfigurationProperty("dependencies", IsDefaultCollection = true, IsRequired = true)]
        public DependencyElementCollection Dependency
        {
            get { return ((DependencyElementCollection)base["dependencies"]); }
        }


    }
    public class DependencyElement : ConfigurationElement 
    {
        internal string _ElementName = "dependency";
        public DependencyElement()
        {
        }
        
        protected override bool SerializeElement(System.Xml.XmlWriter writer, bool serializeCollectionKey)
        {
            bool result = false;
            if (!base.SerializeElement(null, false))
                return false;

            if (writer != null)
            {
                writer.WriteStartElement(this._ElementName);
                result |= base.SerializeElement(writer, false);
                writer.WriteEndElement();
                return result;
            }

            return (result | base.SerializeElement(writer, false));
        }

        [ConfigurationProperty("dependencyType", IsRequired = true)]
        public string DependencyType
        {
            get { return (string)base["dependencyType"]; }
            set { base["dependencyType"] = value; }
        }
        [ConfigurationProperty("value", IsRequired = true)]
        public string Value
        {
            get { return (string)base["value"]; }
            set { base["value"] = value; }
        }
        [ConfigurationProperty("enabled")]
        public bool Enabled
        {
            get { return (bool)base["enabled"]; }
            set { base["enabled"] = value; }
        }
        [ConfigurationProperty("title")]
        public string Title
        {
            get { return (string)base["title"]; }
            set { base["title"] = value; }
        }
        [ConfigurationProperty("explination")]
        public string Explination
        {
            get { return (string)base["explination"]; }
            set { base["title"] = value; }
        }
        [ConfigurationProperty("downloadUrl")]
        public string DownloadUrl
        {
            get { return (string)base["downloadUrl"]; }
            set { base["downloadUrl"] = value; }
        }

        [ConfigurationProperty("infoUrl")]
        public string InfoUrl
        {
            get { return (string)base["infoUrl"]; }
            set { base["infoUrl"] = value; }
        }

        [ConfigurationProperty("scriptName")]
        public string ScriptName
        {
            get { return (string)base["scriptName"]; }
            set { base["scriptName"] = value; }
        }

        [ConfigurationProperty("optional")]
        public bool Optional
        {
            get { return (bool)base["optional"];}
            set { base["optional"] = value;}
        }

    }
}
